Skip to content

Add throwable turtle shell and NPC racing opponents#1

Open
Makio64 wants to merge 1 commit intomrdoob:masterfrom
Makio64:feature/shell-projectile
Open

Add throwable turtle shell and NPC racing opponents#1
Makio64 wants to merge 1 commit intomrdoob:masterfrom
Makio64:feature/shell-projectile

Conversation

@Makio64
Copy link
Copy Markdown

@Makio64 Makio64 commented Apr 20, 2026

Summary

  • Press Space (or gamepad A) to throw a bouncy turtle-shell projectile that ricochets off walls, hits other cars, and is capped to 3 active shells on a 1.5 s cooldown.
  • The three NPC trucks are now racing opponents (kinematic waypoint following around the outer track) instead of static props.
  • Shell hits cause a dramatic Mario-Kart-style spin: target cars whirl for ~2.2 s with a vertical hop and tilt wobble; a shell ricocheting back into the player stuns the player the same way.
  • Hit burst: expanding yellow ring + pooled gold emissive stars with gravity, triggered from the impact point.

Files

  • js/Shell.js (new) — projectile class: small dynamic sphere, gravityFactor: 0, speed-clamped after each bounce, 6 s lifetime, 150 ms owner-ignore window. Turtle-carapace visual built from a flattened dome + hex bumps + rim + belly.
  • js/NPC.js (new)NPC class with a kinematic box body in OL_MOVING, outer-loop waypoint list, smooth heading lerp, spin/hop/tilt hit state.
  • js/HitFX.js (new) — pooled ring + star burst effect.
  • js/Vehicle.jsstun() method + stun-state branch in update(): locks input, spins the container, hops + tilts the body node.
  • js/Controls.js — rising-edge fire input on Space / gamepad button 0, returned as input.fire.
  • js/Track.js — export NPC_TRUCKS, drop the inline static-clone loop (ownership moved to NPC.js driven from main.js).
  • js/main.js — wire everything: createNPCs, HitFX, shell pool, rewritten contact listener that dispatches to shells and triggers the appropriate stun/hit/burst. Bodies are destroyed outside the contact callback to avoid re-entrancy issues.

Test plan

  • Serve the repo statically (python3 -m http.server) and open index.html.
  • Drive with WASD; press Space — green turtle shell flies forward from the car, spinning, at a constant speed.
  • Aim at a wall — shell bounces and keeps going; stays on the ground plane (no vertical hop).
  • Aim at a moving NPC truck — shell disappears on contact, truck spins/hops/tilts for ~2.2 s with ring + stars, then resumes waypoint racing.
  • Fire into a corner so the shell comes back — player gets stunned the same way.
  • Hold Space — only one shell per 1.5 s (rising-edge input).
  • Leave shells to expire — no body/mesh leaks; scene.children stabilises.
  • Existing wall-collision impact audio still plays when the player hits walls.

🤖 Generated with Claude Code

- Press Space (or gamepad A) to throw a bouncy turtle shell projectile that ricochets off walls and knocks trucks into a spin
- Convert the three static NPC trucks into kinematic waypoint-following racers looping around the outer track
- Shell hit spins target ~22 rad/s for 2.2 s with vertical hop and tilt wobble; ricochet also stuns the player
- Hit burst effect: expanding yellow ring plus pooled gold stars with gravity

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented Apr 22, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants